<%@page import="sever.StudentService"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="sever.*,entity.*,java.util.*,java.text.*"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
    <%
    int stuno=Integer.parseInt(request.getParameter("stuno"));
    StudentService studentService=new StudentService();
    Student stu=studentService.cha(stuno);
    
    SimpleDateFormat  sf=new SimpleDateFormat("yyyy-MM-dd");
    
    String birthday=null;
    String enterdate=null;
    if(stu.getBirthday()!=null){
    	birthday=sf.format(stu.getBirthday());
    }
    if(stu.getEnterdate()!=null){
    	enterdate=sf.format(stu.getEnterdate());
    }
    %>
    
    	<form action="StudentUpdate.jsp" method="get">
    		<p>

			<label>学号</label> <input type="text" required name="stuno" value=<%=stuno %> readonly="readonly" />

		</p>
		<p>

			<label>姓名</label> <input type="text" required name="sname" value=<%=stu.getSname() %> />

		</p>
			<p>
	
	<label>性别：</label>
	
<input type="radio" required name="sex" value="男" <%=stu.getSex().equals("男")?"checked":""%> />	男
<input type="radio" required name="sex" value="女" <%=stu.getSex().equals("女")?"checked":""%>  />	女
	<input type="radio" required name="sex" value="妖" <%=stu.getSex().equals("妖")?"checked":"" %> />妖
	</p>

		<p>
			<label>电话</label> <input type="tel" required name="telephone"  value=<%=stu.getTelephone() %> />
		</p>
		<p>
			<label>qq</label> <input type="text" required name="qq" value=<%=stu.getQq()%> />
		</p>
		<p>
			<label>微信</label> <input type="text" required name="wechat" value=<%=stu.getWechat()%> />
		</p>
		<p>
			年级
			<%
			GradeService service = new GradeService();
			List<Grade> list = service.findall2();
		%>
			<select name="gradeid">
				<%
					for (Grade g : list) {
				%>
				<option selected value="<%=g.getId()%>"><%=g.getGname()%></option>
				<%
					}
				%>
			</select>
		</p>
		<p>
			<label>入学日期</label> <input type="text" required name="enterdate" value=<%=enterdate%> />
		</p>
		<p>
			<label>城市</label> <input type="text" required name="fromcity" value=<%=stu.getFromcity()%> />
		</p>
		<p>
			<label>生日</label> <input type="text" required name="birthday" value=<%=birthday%> />
		</p>
		<p>
			<label>地址</label> <input type="text" required name="address" value=<%=stu.getAddress()%> />
		</p>

		<p>
			<input type="submit" value="保存" />
		</p>
    	</form>
</body>
</html>